package com.fm618.flex
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.FileFilter;
	import flash.net.FileReference;
	
	import mx.utils.ObjectUtil;
	import mx.containers.Canvas;
	import mx.controls.Button;
	import mx.controls.Image;
	import mx.controls.Label;

	public class UploadPhoto extends Canvas
	{
		/**
		 *
		 */
		private var fileRef:FileReference;
		private var imgfilter:FileFilter;
		private var img1:Image;
		private var L2:Label;
		
		/**
		 * 构造函数
		 */
		public function UploadPhoto()
		{
			super();
			/*
			imgfilter = new FileFilter("Image", "*.png;*.jpg;*jpeg;*JPEG");
			
			fileRef  = new FileReference();
			fileRef.addEventListener(Event.COMPLETE, frComplete);
			fileRef.addEventListener(Event.OPEN, frOpen);
			fileRef.addEventListener(Event.CANCEL, frCancel);
			fileRef.addEventListener(Event.SELECT, frSelect);
			
			var can1:Canvas = new Canvas();
			can1.width = 400;
			can1.height = 100;
			can1.setStyle('horizontalCenter', '0');
			can1.setStyle('verticalCenter', '0');
			can1.setStyle('backgroundColor', '#cccccc');
			
			var L1:Label = new Label();
			L1.text = '请选择一张照片';
			L1.setStyle('horizontalCenter', '0');
			L1.y = 10;
			can1.addChild(L1);
			
			img1 = new Image();
			img1.width = 200;
			img1.height = 200;
			//can1.addChild(img1);
			
			L2 = new Label();
			L2.text = '……';
			L2.setStyle('horizontalCenter', '0');
			L2.y = 30;
			can1.addChild(L2);
			
			var btn1:Button = new Button();
			btn1.label = '上传';
			btn1.y = 50;
			btn1.addEventListener(MouseEvent.CLICK, selectFile);
			can1.addChild(btn1);
			
			
			
			addChild(can1);*/
		}
		/*
		private function selectFile(e:MouseEvent):void{
			fileRef.browse([imgfilter]);
		}
		
		private function frComplete(e:Event):void{
			//this.img1.source = fileRef.data;
		}
		
		private function frOpen(e:Event):void{
			
		}
		
		private function frSelect(e:Event):void{
			trace(fileRef.name);
			//this.fileRef.load();
			this.L2.text = '文件名：'+fileRef.name + '文件大小：'+fileRef.size + '文件类型：'+fileRef.type;
		}
		
		private function frCancel(e:Event):void{
			
		}*/
	}
}